﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVCT6.Models;

namespace MVCT6.Controllers
{
    public class HomeController : Controller
    {
       

        // GET: Home
        public ActionResult Index()
        {


            using (fashionshoppingDBEntities dB =new fashionshoppingDBEntities())
            {
                IEnumerable<Product> products = dB.Product.ToList();
            return View(products);
            }
        }



        public ActionResult login()
        {
            return View();
        }
        //登录的GET
        [HttpPost]
        public ActionResult login(Users users)
        {
            using (fashionshoppingDBEntities dB = new fashionshoppingDBEntities())
            {
                if (ModelState.IsValid)
                {
                    Users login = dB.Users.FirstOrDefault(u => u.email == users.email && u.pwd == users.pwd);
                   if (login == null)
                    {
                        ModelState.AddModelError("", "账号或密码错误！");
                    }
                }
            
            }
                return View();
        }
    }
}